@extends('layouts.app')
@section('header')
     @include('common.header')
@stop
@section('title', $category->seo_title)
@section('content')
<div class="banner1"></div>
<div class="sjfw">

                <div class="xzzynr">
                    <div class="mjzh_ss">
                    @if($keyword)
                        <div class="ss_text">
                            <p>匹配<a href="">{{$keyword}}</a>的文章共计 {{($total)}}篇（以下文档经本站审核有效，所有文档须下载后进行查看）</p>
                        </div>
                    @else
                        <div class="ss_text">
                            <p>经本站审核有效，所有文档须下载后进行查看</p>
                        </div>
                    @endif

                        <div class="ssnr" style="float:right">
                        <form class="form-horizontal" method="get"  action="{{url($category->controller.'?catid='.$category->id)}}">
            <input class="wby4" name="catid" type="hidden" value="{{$category->id}}">
                            <input class="wby4" name="keyword" type="text">
                            <input class="btn3" name="" type="submit" value="搜索">
                          </form>  
                        </div>
                    </div>

                    <div id="tbody">
                    @foreach($pageList as $row)
                    <div class="xzbox" style="    padding: 15px 0;"><h2 style="margin-bottom: 0">
                    
                    @if($row->price >0)
                                        
                                        	@guest
                                        	<a href="javascript:;"  onclick="buy({{$row->id}})" class="btn5 free fr">购买({{$row->price}}元)</a>
                                        	@else
                                        		@if($row->buys)
                                        			<a href="{{url('upload').'/'.$row->download}}" class="btn5 free fr">下载（已购）</a>
                                            	@else
                                            		<a href="javascript:;" onclick="buy({{$row->id}})" class="btn5 free fr">购买({{$row->price}}元)</a>	
                                            		
                                            	@endif
                                        	@endguest
                                        	
                                        @else
                                        	
                                        <a href="{{url('upload').'/'.$row->download}}" class="btn5 free fr">免费下载</a>
                                        @endif
                    <!-- {{$row->updated_at->year}}_ -->
                    <a href="javascript:;" class="download"><i class="{{$row->post_source}}"></i><i style="color: #00A2E3;    font-size: 18px;">{!!str_replace($keyword,"<font color=red>{$keyword}</font>", $row->post_title)!!}</i></a></h2><p></p><h4 style="padding-top: 0"><span>{{$row->updated_at->toDateString()}}</span>|<span>{{$row->post_hits}}次下载</span>|<span>￥{{$row->price}}</span>|<span>贡献者：{{$row->author}}</span>|<span >质量<em style="color: #00A2E3;">{{$row->good}}</em>分</span></h4></div>
                    @endforeach	
                    </div>

                </div>
                <div class="dede_pages"><ul class="pagelist">
{{ $pageList->links('common.paginator', [ 'results'=>$pageList ]) }}
</ul></div>
                
            </div>
<script type="text/javascript">

function buy(id)
{
	if(uid <=0)window.location.href='/login'

	ajaxurl('/user/buy', {item_id:id, item_type:'article'}, function(res){
		var index = layer.open({
			  title: '信息提示'
			  ,content: res.msg,
			  yes: function(){
				if(res.status == 2){
					window.location.reload();
				}
                if(res.status == 1){
                    window.location.href = '/user/recharge';
                }
				layer.close(index);
			}
			}); 
		
	});
}

</script>
<style>
.btn5{
	display: inline-block;
    height: 20px;
    line-height: 20px;
    color: #fff!important;
    background: #e88446;
    padding: 5px;
    width: 100px;
	font-size: 12px;
    text-align: center;
    Transition: all 0.4s;

}
</style>
@endsection
@section('footer')
     @include('common.footer')
@stop